package bb.lanxing.lib.kt;

//import com.parse.codec.CharEncoding;
import java.nio.charset.Charset;
import java.util.List;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.CharsKt;
import kotlin.text.StringsKt;
/* compiled from: StringExt.kt */
@Metadata(d1 = {"\u0000\u0018\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u0012\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\u001a\u0012\u0010\u0000\u001a\u00020\u0001*\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u0001\u001a\u0012\u0010\u0003\u001a\u00020\u0001*\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u0001\u001a\n\u0010\u0004\u001a\u00020\u0001*\u00020\u0001\u001a\u0014\u0010\u0005\u001a\u00020\u0006*\u00020\u00012\b\b\u0002\u0010\u0007\u001a\u00020\b\u001a\n\u0010\t\u001a\u00020\u0006*\u00020\u0001\u001a\u0014\u0010\n\u001a\u00020\u0001*\u00020\u00012\b\b\u0002\u0010\u0007\u001a\u00020\b¨\u0006\u000b"}, d2 = {"addFirst", "", "s", "addLast", "addSpaceEvery2Charts", "ascii2ByteArray", "", "hasSpace", "", "hex2ByteArray", "reversalEvery2Charts", "lib-devices-api_release"}, k = 2, mv = {1, 7, 1}, xi = 48)

public final class StringExtKt {
    public static /* synthetic */ String reversalEvery2Charts(String str, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            z = false;
        }
        return reversalEvery2Charts(str, z);
    }

    public static String reversalEvery2Charts(String str, boolean z) {
        Intrinsics.checkNotNullParameter(str, "<this>");
        String addSpaceEvery2Charts = addSpaceEvery2Charts(str);
        String str2 = " ";
//        List reversed = CollectionsKt.reversed(StringsKt.split((CharSequence) addSpaceEvery2Charts, new String[]{str2}, false, 0, 6, (Object) null));
        if (!z) {
            str2 = "";
        }
//        return CollectionsKt.joinToString(reversed, str2, null, null, 0, null, null, 62, null);
        return null;
    }

    public static String addSpaceEvery2Charts(String str) {
        Intrinsics.checkNotNullParameter(str, "<this>");
        String replace = str;//StringsKt.replace(str, " ", "", false, 4, (Object) null);
        StringBuilder sb = new StringBuilder();
        int length = replace.length() / 2;
        for (int i = 0; i < length; i++) {
            int i2 = i * 2;
            String substring = replace.substring(i2, i2 + 2);
            Intrinsics.checkNotNullExpressionValue(substring, "this as java.lang.String…ing(startIndex, endIndex)");
            sb.append(substring);
            sb.append(" ");
        }
        String sb2 = sb.toString();
        Intrinsics.checkNotNullExpressionValue(sb2, "sb.toString()");
        return StringsKt.trim(sb2).toString();
    }

    public static byte[] hex2ByteArray(String str) {
        Intrinsics.checkNotNullParameter(str, "<this>");
        String replace = str;//StringsKt.replace(str, " ", "", false, 4, (Object) null);
        byte[] bArr = new byte[replace.length() / 2];
        int length = replace.length() / 2;
        for (int i = 0; i < length; i++) {
            int i2 = i * 2;
            String substring = replace.substring(i2, i2 + 2);
            Intrinsics.checkNotNullExpressionValue(substring, "this as java.lang.String…ing(startIndex, endIndex)");
            bArr[i] = (byte) Integer.parseInt(substring, CharsKt.checkRadix(16));
        }
        return bArr;
    }

    public static /* synthetic */ byte[] ascii2ByteArray(String str, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            z = false;
        }
        return ascii2ByteArray(str, z);
    }

    public static byte[] ascii2ByteArray(String str, boolean z) {
        Intrinsics.checkNotNullParameter(str, "<this>");
        if (!z) {
//            str = StringsKt.replace(str, " ", "", false, 4, (Object) null);
        }
        /*CharEncoding.US_ASCII*/
        Charset forName = Charset.defaultCharset();
        Intrinsics.checkNotNullExpressionValue(forName, "forName(charsetName)");
        byte[] bytes = str.getBytes(forName);
        Intrinsics.checkNotNullExpressionValue(bytes, "this as java.lang.String).getBytes(charset)");
        return bytes;
    }

    public static String addFirst(String str, String s) {
        Intrinsics.checkNotNullParameter(str, "<this>");
        Intrinsics.checkNotNullParameter(s, "s");
        return s + str;
    }

    public static String addLast(String str, String s) {
        Intrinsics.checkNotNullParameter(str, "<this>");
        Intrinsics.checkNotNullParameter(s, "s");
        return str + s;
    }
}
